package com.example.aqarapp.model;

import org.json.JSONObject;

import java.io.DataOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import javax.net.ssl.HttpsURLConnection;

public class LoginModel {

    public static final String mUrl = "https://open-cn.aqara.com/v3.0/open/api";

    public LoginModel(){

    }

    public void httpsConnection(String data) throws IOException {
        URL myURL = new URL(mUrl);
        HttpsURLConnection httpsConn = (HttpsURLConnection) myURL.openConnection();
        httpsConn.setRequestMethod("POST");
        httpsConn.setConnectTimeout(5000);
        httpsConn.setReadTimeout(5000);
        httpsConn.setRequestProperty("Content-Type", "application/json");


        DataOutputStream out = new DataOutputStream(
                httpsConn.getOutputStream());
        out.writeBytes(data);
        out.flush();
        out.close();
    }

    public void getAuthCode() {

    }

//    public JSONObject getToken(JSONObject requestData) {
//        return
//    }


}
